import Vue from 'vue';
import VueRouter from "vue-router";
import VueResource from 'vue-resource';
import Vuex from 'vuex';
import SocketIO from 'socket.io-client';
import routes from "./router.admin";
import comUtil from './util/comUtil';

// element-ui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-default/index.css';

// font-awesome
import '../font/font-awesome/font-awesome.css';

// css
import '../css/admin.css';

// 组件注册
Vue.use(VueRouter);
Vue.use(VueResource);
Vue.use(Vuex);

// 注册ElementUI
Vue.use(ElementUI);

const router = new VueRouter({
    routes: routes
});

// 全局状态管理
const store = new Vuex.Store({
    state: {
        socket: SocketIO('http://localhost:8360')
    },
    mutations: {}
});

// 指定组件的渲染和观察期间未捕获错误的处理函数
Vue.config.errorHandler = function (err, vm) {
    console.error('admin.error:' + err);
};

// Admin
import Admin from '../components/admin/index.vue';

// 注册实例，挂载节点
const vm = new Vue({
    router,
    store,
    render: h => h(Admin)
}).$mount('#app');

window.vm_admin = vm;